window.onload=function(){
     //切换页面
    // var parentWindow=window.parent;
    // var iframe=document.querySelector("iframe");
    // var iframe=parentWindow.document.getElementsByTagName("iframe")[0];
    // var change1 = document.getElementsByClassName("change1")[0];
    // var list = change1.getElementsByTagName("li");
    // for (let i = 0; i < list.length; i++) {
        // list[i].onclick = function () {
            // for (var j = 0; j < list.length; j++) {
                // list[j].className = "";
            // }
            // this.className = "active";
            // if(i===0){
                // 页面刷新时任然停留在本页面
                // location.hash="#homePage";
                // iframe.src="../views/homePage.html";
            // }else if(i===1){
                // parentWindow.dealData.set("fromHome",false);
                // iframe.src="../views/selfChoose.html";
            // }else if(i===3){
                // iframe.src="../views/consultService.html";
            // }
        // }
    // }




    // var iframe = document.querySelector("iframe");
    // if(location.hash===""){
        // iframe.src="../views/homePage.html";
    // }else{
        // iframe.src = `../views/${location.hash.substring(1)}.html`;
    // }

    // 监听当前页面的hash值的变化，一旦变化即触发该事件
    // window.onhashchange = function () {
        // var hashMap = { 
            // homePage: "../views/homePage.html",
            // selfChoose: "../views/selfChoose.html",
            // consultService: "../views/consultService.html"
        // };
        // 截取当前页面hash值
        // var hash = location.hash.substring(1);
        // iframe.src = hashMap[hash];
    // }
}



//页面刷新时任然停留在本页面效果
//需要写在加载函数外面
 window.addEventListener("DOMContentLoaded",function(){
    //  当dom树加载构建完成后执行
     var parentWindow=window.parent;
     var change1 = document.getElementsByClassName("change1")[0];
     var list = change1.getElementsByTagName("li");
     var iframe=document.querySelector("iframe");
     var parentWindow=window.parent;
var change1 = document.getElementsByClassName("change1")[0];
var iframe=document.querySelector("iframe");
var list = change1.getElementsByTagName("li");
    //获取当前的hash值，并执行相应的函数
function getHash(option){
    var hash=location.hash.substring(1);
    option[hash]();
}
     
//给window绑定多个事件
function on(events,callback){
    var event=events.split(" ");
    for(var e in event){
        window.addEventListener(event[e],callback);
    }
}
//给window绑定加载和hash值改变事件
on("load hashchange",function(){
    getHash({
        //首页切换
        "homePage":function(){
            iframe.src="../views/homePage.html";
            for (var j = 0; j < list.length; j++) {
                list[j].className = "";
            }
            list[0].className="active";
        },
        "":function(){
           location.hash="#homePage";
        },
        //自选切换
        "selfChoose":function(){
            iframe.src="../views/selfChoose.html";
            // location.hash="#selfChoose";
            dealData.set("setSelfChoose",true);
            for (var j = 0; j < list.length; j++) {
                list[j].className = "";
            }
            list[1].className="active";
        },
        //咨询切换
        "consultService":function(){
            iframe.src="../views/consultService.html";
            for (var j = 0; j < list.length; j++) {
                list[j].className = "";
            }
            list[3].className="active";
        },
    });
})
 });
// 
